/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lectescrxml;

import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.parsers.ParserConfigurationException;
import org.jespxml.JespXML;
import org.jespxml.excepciones.TagHijoNotFoundException;
import org.jespxml.modelo.Atributo;
import org.jespxml.modelo.Tag;
import org.xml.sax.SAXException;
/**
 *
 * @author cfchilito
 */
public class LectEscrXml {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        JespXML xml = new JespXML(new File("tmp.xml"));
        try {
            Tag ofertas = xml.leerXML();
            System.out.println(ofertas.getNombre());
            for (Tag oferta : ofertas.getTagsHijos()){
                System.out.println(oferta);
                Tag id, nombre, fichero, macro, autor ;
                id = oferta.getTagHijoByName("id");
                nombre = oferta.getTagHijoByName("nombre");
                macro = oferta.getTagHijoByName("macro");
                autor = oferta.getTagHijoByName("autor");
                System.out.println(oferta);    
                System.out.println(id);    
                System.out.println(nombre);    
                System.out.println(macro);  
                System.out.println(autor);
                
        }
        } catch (ParserConfigurationException ex) {
            Logger.getLogger(LectEscrXml.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SAXException ex) {
            Logger.getLogger(LectEscrXml.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(LectEscrXml.class.getName()).log(Level.SEVERE, null, ex);
        } catch (TagHijoNotFoundException ex) {
            Logger.getLogger(LectEscrXml.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
    }
